<?php

namespace App\Http\Controllers;

use Illuminate\Auth\Access\Response;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\User;
use DB;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $arr = $this->layoutData();

        return view('home-index')->with($arr);
    }

    /**
     * 获取我的收藏
     * @return mixed
     */
    public function getMyStow()
    {
        $stow = DB::table('stow')->where('uid',Auth::id())->get();
//        return Response::json(['code'=>0, 'msg'=>'', 'data'=>$stow]);
        $arr = array_merge($this->layoutData(), ['data'=>$stow]);
        return view('home-mystow')->with($arr);
    }

    /**
     * 获取我的发言
     * @return mixed
     */
    public function getMySay()
    {
        $say = DB::table('comments')->where('uid',Auth::id())->get();
//        return $say;
        $arr = array_merge($this->layoutData(), ['data'=>$say]);
        return view('home')->with($arr);
    }

    /**
     * 获取我发布的内容
     * @return mixed
     */
    public function getMyCont()
    {
        $cont = DB::table('matter')->where('uid',Auth::id())->get();
        $arr = array_merge($this->layoutData(), ['data'=>$cont]);
        return view('home')->with($arr);
    }

    /**
     * 获取我订阅的
     */
    public function getSubscribe()
    {

    }
}
